package com.kaifamiao.N0729;

import java.util.Scanner;

public class Test3 {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("请输入宠物，1：狗狗。2：小鸟。");
        int choice = input.nextInt();
        Pet pet = null;
        switch(choice){
            case 1:
                pet = new Dog();
                break;
            case 2:
                pet = new Bird();
                break;
        }
        pet.toHospital();
        if(pet instanceof Dog){
            Dog dog = (Dog) pet;
            dog.catchingFlyDisc();
        }
        if(pet instanceof Bird){
            Bird bird = (Bird) pet;
            bird.fly();
        }
    }
}
